$().ready(function(){
    $(".fancybox").fancybox();         
})
function load_elfinder($id) {

    
    
    
    

    $('<div id="elfinder" />').elfinder({
        url : base_url + '/sysadmin/elfinder/connector',
        lang : 'en',
        dialog : {
            width : 900, 
            modal : true
        },
        closeOnEditorCallback : true, // close after file select     // pass callback to file manager
        editorCallback : function(url) {
            document.getElementById($id).value = url; 
        },
        commandsOptions: {
            getfile: {
                oncomplete: 'close' // destroy elFinder after file selection
            }
        }
    })
    
}
function ham_x(obj){
    target =$(".form_pick").find("input:checked:not(.select-on-check-all)");
    if(target.length > 0)
        return (target.val());
    return false;
}
function add_btn2(ed){
    var text = ed.selection.getContent({
        "format" : "text"
    });
    if (text && text.length > 0) {
        ed.execCommand("mceInsertContent",false,"<span class='accordion_middle'><span class='accordion_middle-wrapper'>"+text+"</span></span>");
    }

}
function add_btn_trans(ed){
    btn_trans = '<button class="enab_tip btn btn-small">Bật lời dịch</button>';
    ed.selection.setContent(btn_trans);
    return false;
            
}
function function_x(ed,ctl){
 
     $.ajax({
        url:base_url+'/sysadmin/raudio.html',
        type:'post',
        success:function(data){
            bootbox.dialog(data, [{
                    "label" : "Success!",
                    "class" : "btn-success pick_btn pull-left",
                    "icon"  : "icon-ok-sign icon-white"
                }]);
            
            $('.pick_btn').click(function(e){
                e.preventDefault();
                var data=$(".rAudio").serialize();
               
               getdataByID(data);
               
                return false;
            })
            }   
        })
}

function getdataByID(data){
    
    $.ajax({
        
        url:base_url+'/sysadmin/raudio/getDatabyID.html',
        data: data,
        success: function(data){
            
            bootbox.alert(data);
            
        }
        
    });
    
}
    //    $.fancybox({
    //        'padding':10,
    //        'autoScale': true,
    //        'transitionIn': 'fade',
    //        'transitionOut': 'fade',
    //        'type': 'inline',
    //        'autoResize' : true,
    //        
    //        'href': base_url+"/sysadmin/"+ctl+"/pick.html",
    //        beforeClose: function(){
    //             if($("#confirm").val()=="ok"){
    //                 val = ham_x();
    //                 if(val){
    //                     ct = "[AUDIO[ID="+val+"]]";
    //                   ed.selection.setContent(ct);
    //                 } 
    //            }
    //        }
    // });
    //ed.selection.setContent("<object type=application/x-shockwave-flash data=http://localhost/06.WWW/themes/default/assets/js/jwplayer/player.swf width=100% height=100% ><param name=allowfullscreen value=true><param name=allowscriptaccess value=always><param name=seamlesstabbing value=true><param name=wmode value=opaque><param name=flashvars value=netstreambasepath=http%3A%2F%2Flocalhost%2F06.WWW%2F&amp;id=mp3player1200&amp;file=%2Fuploads%2Faudio%2Fdanhngon.mp3&amp;autostart=true&amp;skin=http%3A%2F%2Flocalhost%2F06.WWW%2Fthemes%2Fdefault%2Fassets%2Fjs%2Fjwplayer%2Fnikitaskin.zip&amp;controlbar.position=bottom></object>");
    //alert("x");